subroutine allocate_particles()
  use particles
  implicit none

  ! Coordinates
  if(allocated(In0%Coordinates)) deallocate(In0%Coordinates)
  allocate(In0%Coordinates(3,header%NumPart_ThisFile(1)))
  if(.NOT.(allocated(In0%Coordinates))) call abort('  -Failed to allocate In0%Coordinates')
  In0%Coordinates = 0.0e0

  if(allocated(In1%Coordinates)) deallocate(In1%Coordinates)
  allocate(In1%Coordinates(3,header%NumPart_ThisFile(2)))
  if(.NOT.(allocated(In1%Coordinates))) call abort('  -Failed to allocate In1%Coordinates')
  In1%Coordinates = 0.0e0  

  if(allocated(In2%Coordinates)) deallocate(In2%Coordinates)
  allocate(In2%Coordinates(3,header%NumPart_ThisFile(3)))
  if(.NOT.(allocated(In2%Coordinates))) call abort('  -Failed to allocate In2%Coordinates')
  In2%Coordinates = 0.0e0  

  if(allocated(In3%Coordinates)) deallocate(In3%Coordinates)
  allocate(In3%Coordinates(3,header%NumPart_ThisFile(4)))
  if(.NOT.(allocated(In3%Coordinates))) call abort('  -Failed to allocate In3%Coordinates')
  In3%Coordinates = 0.0e0  

  if(allocated(In4%Coordinates)) deallocate(In4%Coordinates)
  allocate(In4%Coordinates(3,header%NumPart_ThisFile(5)))
  if(.NOT.(allocated(In4%Coordinates))) call abort('  -Failed to allocate In4%Coordinates')
  In4%Coordinates = 0.0e0  

  if(allocated(In5%Coordinates)) deallocate(In5%Coordinates)
  allocate(In5%Coordinates(3,header%NumPart_ThisFile(6)))
  if(.NOT.(allocated(In5%Coordinates))) call abort('  -Failed to allocate In5%Coordinates')
  In5%Coordinates = 0.0e0

  ! ParticleIDs
  if(allocated(In0%ParticleIDs)) deallocate(In0%ParticleIDs)
  allocate(In0%ParticleIDs(header%NumPart_ThisFile(1)))
  if(.NOT.(allocated(In0%ParticleIDs))) call abort('  -Failed to allocate In0%ParticleIDs')
  In0%ParticleIDs = 0

  if(allocated(In1%ParticleIDs)) deallocate(In1%ParticleIDs)
  allocate(In1%ParticleIDs(header%NumPart_ThisFile(2)))
  if(.NOT.(allocated(In1%ParticleIDs))) call abort('  -Failed to allocate In1%ParticleIDs')
  In1%ParticleIDs = 0

  if(allocated(In2%ParticleIDs)) deallocate(In2%ParticleIDs)
  allocate(In2%ParticleIDs(header%NumPart_ThisFile(3)))
  if(.NOT.(allocated(In2%ParticleIDs))) call abort('  -Failed to allocate In2%ParticleIDs')
  In2%ParticleIDs = 0  

  if(allocated(In3%ParticleIDs)) deallocate(In3%ParticleIDs)
  allocate(In3%ParticleIDs(header%NumPart_ThisFile(4)))
  if(.NOT.(allocated(In3%ParticleIDs))) call abort('  -Failed to allocate In3%ParticleIDs')
  In3%ParticleIDs = 0  

  if(allocated(In4%ParticleIDs)) deallocate(In4%ParticleIDs)
  allocate(In4%ParticleIDs(header%NumPart_ThisFile(5)))
  if(.NOT.(allocated(In4%ParticleIDs))) call abort('  -Failed to allocate In4%ParticleIDs')
  In4%ParticleIDs = 0  

  if(allocated(In5%ParticleIDs)) deallocate(In5%ParticleIDs)
  allocate(In5%ParticleIDs(header%NumPart_ThisFile(6)))
  if(.NOT.(allocated(In5%ParticleIDs))) call abort('  -Failed to allocate In5%ParticleIDs')
  In5%ParticleIDs = 0

  ! Velocity
  if(allocated(In0%Velocity)) deallocate(In0%Velocity)
  allocate(In0%Velocity(3,header%NumPart_ThisFile(1)))
  if(.NOT.(allocated(In0%Velocity))) call abort('  -Failed to allocate In0%Velocity')
  In0%Velocity = 0.0e0

  if(allocated(In1%Velocity)) deallocate(In1%Velocity)
  allocate(In1%Velocity(3,header%NumPart_ThisFile(2)))
  if(.NOT.(allocated(In1%Velocity))) call abort('  -Failed to allocate In1%Velocity')
  In1%Velocity = 0.0e0  

  if(allocated(In2%Velocity)) deallocate(In2%Velocity)
  allocate(In2%Velocity(3,header%NumPart_ThisFile(3)))
  if(.NOT.(allocated(In2%Velocity))) call abort('  -Failed to allocate In2%Velocity')
  In2%Velocity = 0.0e0  

  if(allocated(In3%Velocity)) deallocate(In3%Velocity)
  allocate(In3%Velocity(3,header%NumPart_ThisFile(4)))
  if(.NOT.(allocated(In3%Velocity))) call abort('  -Failed to allocate In3%Velocity')
  In3%Velocity = 0.0e0  

  if(allocated(In4%Velocity)) deallocate(In4%Velocity)
  allocate(In4%Velocity(3,header%NumPart_ThisFile(5)))
  if(.NOT.(allocated(In4%Velocity))) call abort('  -Failed to allocate In4%Velocity')
  In4%Velocity = 0.0e0  

  if(allocated(In5%Velocity)) deallocate(In5%Velocity)
  allocate(In5%Velocity(3,header%NumPart_ThisFile(6)))
  if(.NOT.(allocated(In5%Velocity))) call abort('  -Failed to allocate In5%Velocity')
  In5%Velocity = 0.0e0

  !Mass
  if(allocated(In0%Mass)) deallocate(In0%Mass)
  allocate(In0%Mass(header%NumPart_ThisFile(1)))
  if(.NOT.(allocated(In0%Mass))) call abort('  -Failed to allocate In0%Mass')
  In0%Mass = 0.0e0  

  if(allocated(In1%Mass)) deallocate(In1%Mass)
  allocate(In1%Mass(header%NumPart_ThisFile(2)))
  if(.NOT.(allocated(In1%Mass))) call abort('  -Failed to allocate In1%Mass')
  In1%Mass = 0.0e0    

  if(allocated(In2%Mass)) deallocate(In2%Mass)
  allocate(In2%Mass(header%NumPart_ThisFile(3)))
  if(.NOT.(allocated(In2%Mass))) call abort('  -Failed to allocate In2%Mass')
  In2%Mass = 0.0e0    

  if(allocated(In3%Mass)) deallocate(In3%Mass)
  allocate(In3%Mass(header%NumPart_ThisFile(4)))
  if(.NOT.(allocated(In3%Mass))) call abort('  -Failed to allocate In3%Mass')
  In3%Mass = 0.0e0    

  if(allocated(In4%Mass)) deallocate(In4%Mass)
  allocate(In4%Mass(header%NumPart_ThisFile(5)))
  if(.NOT.(allocated(In4%Mass))) call abort('  -Failed to allocate In4%Mass')
  In4%Mass = 0.0e0    

  if(allocated(In5%Mass)) deallocate(In5%Mass)
  allocate(In5%Mass(header%NumPart_ThisFile(6)))
  if(.NOT.(allocated(In5%Mass))) call abort('  -Failed to allocate In5%Mass')
  In5%Mass = 0.0e0  

end subroutine allocate_particles
